Running Tests in Parallel
With tempus-fugit, you can easily run tests methods in parallel. Each test method within a class will run on its own thread and in parallel with any other test methods in that class. So, the number of threads for a given test class will be equal to the number of test methods within that class.
Simply mark your test to be @RunWith
the ConcurrentTestRunner
class as below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
In this example, each of the individual test methods are run once but in their own thread, all spawned roughly at the same time. The output from the above might look like the following.
I'm running on thread ConcurrentTestRunner-Thread-0
I'm running on thread ConcurrentTestRunner-Thread-2
I'm running on thread ConcurrentTestRunner-Thread-1
Another run might yield a different interpolation.
I'm running on thread ConcurrentTestRunner-Thread-1
I'm running on thread ConcurrentTestRunner-Thread-0
I'm running on thread ConcurrentTestRunner-Thread-2